<html>
<head>
<title>五子棋（无禁手）-<?php echo $this->roomRow->room_name; ?></title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/public/scripts/public/ajax.js"></script>
<script>
var xmlHttp;

function gameroom_init()
{
	xmlHttp = GetXmlHttpObject();
	time=window.setInterval("room_refresh_send()", 3000);	
}

function room_refresh_send()
{
	var url = '/hdocs/fivechess/room_refresh';
	xmlHttp.open('GET', url, true);
	xmlHttp.onreadystatechange = room_refresh_recv;
	xmlHttp.setRequestHeader('If-Modified-Since', '0');
	xmlHttp.send(null);
}

function room_refresh_recv()
{
	if (xmlHttp.readyState != 4 )
	{
		return false;
	}
	if (xmlHttp.status != 200)
	{
		return false;
	}
	if (!xmlHttp.responseXML)
	{
		return false;
	}
	var gamingChilds = xmlHttp.responseXML.getElementsByTagName('gaming');
	for (var i=0; i < gamingChilds.length; ++i)
	{
		var gaming_id = gamingChilds[i].getElementsByTagName('gaming_id')[0].textContent;
		var host_user = gamingChilds[i].getElementsByTagName('host_user')[0].textContent;
		var guest_user = gamingChilds[i].getElementsByTagName('guest_user')[0].textContent;
		if (host_user)
		{
			document.getElementById('host_user_' + gaming_id).innerHTML = host_user;
			var host_face = gamingChilds[i].getElementsByTagName('host_face')[0].textContent;		
			var host_img = document.getElementById('host_img_' + gaming_id);
			host_img.innerHTML = "<img src='<?php echo $this->imgdir, 'face/'; ?>" + host_face + ".gif'/>";
		}
		else
		{
			document.getElementById('host_user_' + gaming_id).innerHTML = '&nbsp;';
			document.getElementById('host_img_' + gaming_id).innerHTML = 
				"<a href='/hdocs/fivechess/chessboard/gaming_id/" + gaming_id + 
				"/site/host' board='0'><img src='<?php echo $this->imgdir; ?>face/0.gif'/></a>"
		}
		if (guest_user)
		{
			document.getElementById('guest_user_' + gaming_id).innerHTML = guest_user;
			var guest_face = gamingChilds[i].getElementsByTagName('guest_face')[0].textContent;
			var guest_img = document.getElementById('guest_img_' + gaming_id);
			guest_img.innerHTML = "<img src='<?php echo $this->imgdir, 'face/'; ?>" + guest_face + ".gif'/>";
		}
		else
		{
			document.getElementById('guest_user_' + gaming_id).innerHTML = '&nbsp;';
			document.getElementById('guest_img_' + gaming_id).innerHTML = 
				"<a href='/hdocs/fivechess/chessboard/gaming_id/" + gaming_id + 
				"/site/guest' board='0'><img src='<?php echo $this->imgdir; ?>face/0.gif'/></a>"
		}
	}
}



</script>
</head>

<body onLoad="gameroom_init()";  bgcolor="#51719e">
<div>
	<table width='100%'>
		<?php for ($i = 0; $i < count($this->gamingRowSet) / 4; ++$i) : ?>
		<tr>
			<?php for ($j = 0; $j < 4; ++$j): ?>
			<td width="30%">
				<?php $rowId = $i * 4 + $j; 
				if ($rowId < count($this->gamingRowSet)): 
					$gaming = $this->gamingRowSet[$rowId]?>
				<table id='gaming_<?php echo $gaming->gaming_id; ?>' width="120" height="120" align='center' border="0" background="<?php echo $this->imgdir, 'table'; if ($gaming->status){echo '_gaming';} ?>.gif">
					<tr>
						<td></td>
					</tr>
					<tr>
						<td width="32">
						</td>
						<td width="60">
						</td>
						<td id='guest_user_<?php echo $gaming->gaming_id; ?>' width="32" align = 'right'>
							<?php if ($gaming->guest_user){ echo $gaming->guest_user; }
								else{echo '&nbsp;';} ?>
						</td>
					</tr>
					<tr>
						
						<td id='host_img_<?php echo $gaming->gaming_id; ?>' width="32" align='left'>
							<?php if ($this->allUsers[$gaming->host_user]): ?>
								<img id='host_face_<?php echo $gaming->gaming_id; ?>' src='<?php echo $this->imgdir, 'face/';
								echo $this->allUsers[$gaming->host_user]->face;
								echo '.gif'; ?>'>
							<?php else: ?>
								<a href='/hdocs/fivechess/chessboard/gaming_id/<?php echo $gaming->gaming_id;?>/site/host' board='0'>
								<img id='host_face_<?php echo $gaming->gaming_id; ?>' src='<?php echo $this->imgdir, 'face/0.gif'; ?>'>
								</a>
							<?php endif; ?>
						</td>
						<td width="60">
						</td>
						<td id='guest_img_<?php echo $gaming->gaming_id; ?>' width="32" align='right'>
							<?php if ($this->allUsers[$gaming->guest_user]): ?>
								<img id="guest_face_<?php echo $gaming->gaming_id; ?>" src='<?php echo $this->imgdir, 'face/';
								echo $this->allUsers[$gaming->guest_user]->face;
								echo '.gif'; ?>'>
							<?php else: ?>
								<a href='/hdocs/fivechess/chessboard/gaming_id/<?php echo $gaming->gaming_id;?>/site/guest' board='0'>
								<img id="guest_face_<?php echo $gaming->gaming_id; ?>" src='<?php echo $this->imgdir, 'face/0.gif'; ?>'>
								</a>
							<?php endif; ?>
						</td>
					</tr>
					<tr>
						<td id='host_user_<?php echo $gaming->gaming_id; ?>' width="32" align='left'>
							<?php if ($gaming->host_user){ echo $gaming->host_user; }
								else{ echo '&nbsp';}; ?>
						</td>
						<td width="60">
						</td>
						<td width='32'>
						</td>
					</tr>					
					<tr>
						<td></td>
					</tr>
				</table>
				<?php endif; ?>
			</td>
			<?php endfor; ?>
		</tr>
		<?php endfor; ?>
	</table>
</div>
</body>

</html>